﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NBFModel;
using NBFDAL.SqlMapDAL;
using PWMIS.DataMap.Entity;
using System.Data; 

namespace NBFBLL
{
    public class UserListBLL
    {
        private UserInfoDAL userList = new UserInfoDAL();

        public List<TB_zdgl_Users> GetUserList(string strWhere)
        {
            return userList.GetUserList(strWhere);
        }

        public TB_zdgl_Users GetUserModel(string userID)
        {
            return userList.GetSingleUser(userID);
        }

        public TB_zdgl_Users GetSingleUser(string userID)
        {
            TB_zdgl_Users usr = new TB_zdgl_Users();
            usr.UserID = userID;
            EntityQuery<TB_zdgl_Users>.Fill(usr);
            return usr;
        }

        public int InsertUser(TB_zdgl_Users usr)
        {
            
            return EntityQuery<TB_zdgl_Users>.Instance.Insert(usr);
        }

        public int UpdateUser(TB_zdgl_Users usr)
        {
            return EntityQuery<TB_zdgl_Users>.Instance.Update(usr);
        }

        public int DeleteUser(string userid)
        {
            TB_zdgl_Users user = new TB_zdgl_Users();
            user.UserID = userid;
            OQL o = new OQL(user);

            o.Delete().Where(o.Condition.AND(user.UserID, "=", userid));
            int nums = EntityQuery<TB_zdgl_Users>.Instance.ExecuteOql(o);
            return nums;
            
        }
    }
}
